<?php
///
function left_panel(){
	global $lang;
	if($lang=='e')
		$xtpl_left = new XTemplate("../templates/left_e.htm");
	else
		$xtpl_left = new XTemplate("../templates/left.htm");
	$loginAdminID=$_SESSION['loginAdminID'];
	$xtpl_left->assign("name", Welcome." <b>".$loginAdminID."</b>");
	$xtpl_left->parse("LEFT");
	$out_html = $xtpl_left->text("LEFT");
	return $out_html;
}
///
function header_panel(){
	$xtpl_header = new XTemplate("../templates/header.htm");
	$xtpl_header->parse("HEADER");
	$out_html = $xtpl_header->text("HEADER");
	return $out_html;
}
///
function footer_panel(){
	$xtpl_footer= new XTemplate("../templates/footer.htm");
	
	$xtpl_footer->parse("FOOTER");
	$out_html = $xtpl_footer->text("FOOTER");
	return $out_html;
}
///  
function redir($url, $text){
	return '<meta http-equiv="refresh" content="1; url='.$url.'"><b style="color:red"><blink>'.$text.'</blink></b>';
}
///
function check_exist($table, $field, $where){
	$sql="SELECT $field FROM $table WHERE $where";
	$rs=execSQL($sql);
	$num=mysql_num_rows($rs);
	if($num>0)
		return true;
	else
		return false;	
}
///
function cbo_category_tree($row_id,$space)
{	
	$parent_combo_list='';
	$space = $space.'&nbsp;&nbsp;&nbsp;';
	$sttest = "select category_id, category_name, category_name_e from category 
				where parent_id='$row_id' and category_isactive=1
				order by category_position"; 
	$rstest = execSQL($sttest);
	$totaltest = mysql_num_rows($rstest); 
	if($totaltest > 0)
	{				
		while($rowtest = mysql_fetch_array($rstest))
		{	
			$parent_combo_list.= '<option value="'.$rowtest['category_id'].'">'.$space.$rowtest['category_name'].' ('.$rowtest['category_name_e'].')</option>'; 
			$a = $rowtest['category_id']; 
			$parent_combo_list.=cbo_category_tree($a,$space);
		} 
	}
	return $parent_combo_list;
}
///
function cbo_catdestination($value='') {
	global $lang;
	$sql="SELECT catdestination_id, catdestination_name FROM ".pre_table."catdestination WHERE lang='".$lang."'";
	$rs=execSQL($sql);
	if(mysql_num_rows($rs)){
		while($row=mysql_fetch_assoc($rs)){
			if($row['catdestination_id']=="$value"){
				$select=" selected='selected'";
			}else {
				$select="";
			}
			$cbo_cat.="<option value='".$row['catdestination_id']."' ".$select.">".$row['catdestination_name']."</option>";
		}
	}
	return $cbo_cat;
}
///
function cbo_country($value='') {
	global $lang;
	$sql="SELECT country_id, country_name FROM ".pre_table."country WHERE lang='".$lang."'";
	$rs=execSQL($sql);
	if(mysql_num_rows($rs)){
		while($row=mysql_fetch_assoc($rs)){
			if($row['country_id']=="$value"){
				$select=" selected='selected'";
			}else {
				$select="";
			}
			$cbo_cat.="<option value='".$row['country_id']."' ".$select.">".$row['country_name']."</option>";
		}
	}
	return $cbo_cat;
}
///
function cbo_city($country_id, $value='') {
	global $lang;
	$sql="SELECT city_id, city_name FROM ".pre_table."city WHERE country_id='".$country_id."' AND lang='".$lang."'";
	$rs=execSQL($sql);
	if(mysql_num_rows($rs)){
		while($row=mysql_fetch_assoc($rs)){
			if($row['city_id']=="$value"){
				$select=" selected='selected'";
			}else {
				$select="";
			}
			$cbo_cat.="<option value='".$row['city_id']."' ".$select.">".$row['city_name']."</option>";
		}
	}
	return $cbo_cat;
}
///
function cbo_tab($value='') {
	$arr_tab = array("home", "destinations", "tours", "hotels", "otherservices", "daytrips");
	
	foreach($arr_tab as $k => $v){
		if($arr_tab[$k]==$value){
			$select=" selected='selected'";
		}else{
			$select="";
		}
		$cbo_cat.="<option value='".$arr_tab[$k]."' ".$select.">".$arr_tab[$k]."</option>";
	}

	return $cbo_cat;
}
?>